package Exercise;

import java.util.ArrayList;

public class Test115 {
    public static void main(String[] args) {

        ArrayList<Phone> list=new ArrayList<>();
        Phone s1=new Phone("mi",1999);
        Phone s2=new Phone("apple",8999);
        Phone s3=new Phone("meizu",2999);

        list.add(s1);
        list.add(s2);
        list.add(s3);

        ArrayList<Phone> result=new ArrayList<>();
        result=judge(list);
        for (int i = 0; i < result.size(); i++) {
            Phone p=result.get(i);
            System.out.println(p.getBrand()+","+p.getPrice());
        }
    }

    public static ArrayList<Phone> judge(ArrayList<Phone>list){
        ArrayList<Phone> nea=new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            Phone p=list.get(i);
            double price=p.getPrice();
            if(price<3000.0){
                nea.add(p);
            }
        }
        return nea;

    }
}
